package cn.lili.modules.goods.client;

import cn.lili.modules.constant.ServiceConstant;
import cn.lili.modules.goods.entity.dos.Goods;
import cn.lili.modules.goods.fallback.GoodsIndexFallback;
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
import cn.lili.modules.search.entity.dto.EsDeleteDTO;
import cn.lili.modules.search.entity.dto.EsGoodsIndexDTO;
import cn.lili.modules.search.entity.dto.EsGoodsIndexUpdateDTO;
import cn.lili.modules.search.entity.dto.EsGoodsIndexUpdatePromotionsDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author paulG
 * @since 2022/6/20
 **/
@FeignClient(path = "${server.servlet.context-path}", name = ServiceConstant.GOODS_SERVICE, contextId = "goods-index", fallback = GoodsIndexFallback.class)
public interface GoodsIndexClient {

    /**
     * es 商品获取列表
     *
     * @param skuIds skuId集合
     * @return es商品模型集合
     */
    @PostMapping("/feign/goods/es")
    List<EsGoodsIndex> getEsGoodsBySkuIds(@RequestBody List<String> skuIds);

    /**
     * 清除商品索引中无效促销活动
     */
    @GetMapping("/feign/goods/es/promotions/clean")
    void cleanEsGoodsIndexInvalidPromotions();

    @PutMapping("/feign/goods/index/field")
    void updateIndexField(@RequestBody EsGoodsIndexUpdateDTO esGoodsIndexUpdateDTO);

    @PutMapping("/feign/goods/index/promotions/list")
    void updateEsGoodsIndexByList(@RequestBody EsGoodsIndexUpdatePromotionsDTO esGoodsIndexUpdatePromotionsDTO);

    @PutMapping("/feign/goods/index/promotions")
    void updateEsGoodsIndexPromotions(@RequestBody EsGoodsIndexUpdatePromotionsDTO esGoodsIndexUpdatePromotionsDTO);

    @PostMapping("/feign/goods/index/promotions/list/all")
    void updateEsGoodsIndexAllByList(@RequestBody EsGoodsIndexUpdatePromotionsDTO esGoodsIndexUpdatePromotionsDTO);

    @PostMapping("/feign/goods/index")
    void addIndex(@RequestBody EsGoodsIndex goodsIndex);

    @PostMapping("/feign/goods/index/batch")
    void addIndex(@RequestBody List<EsGoodsIndex> goodsIndexDTOList);

    @DeleteMapping("/feign/goods/index")
    void deleteIndex(@RequestBody EsDeleteDTO esDeleteDTO);

    @PutMapping("/feign/goods/index")
    void updateIndex(@RequestBody EsGoodsIndexDTO goodsIndex);


    @PutMapping("/feign/goods/updateGoodsIndex")
    void updateGoodsIndexByGoodsList(@RequestBody List<Goods> goodsList);

    @PutMapping("/feign/goods/updateGoodsIndex/{storeId}")
    void updateGoodsIndexByStore(@PathVariable String storeId);

    @PutMapping("/feign/goods/updateBulkIndex")
    void updateBulkIndex(@RequestBody List<EsGoodsIndex> goodsIndices);

    @GetMapping("/feign/goods/{id}/findById")
    EsGoodsIndex findById(@PathVariable String id);




    /**
     * 获取EsGoodsIndex
     * @param skuId
     * @return
     */
    @GetMapping("/feign/goods/getEsGoodsIndex/")
    EsGoodsIndex getEsGoodsBySkuId(@RequestParam String skuId);


    /**
     * 删除索引中指定的促销活动id的促销活动
     *
     * @param skuIds      商品skuId
     * @param promotionsKey 促销活动Key
     */
    @DeleteMapping("/feign/goods/esGoods/deleteEsGoodsPromotionByPromotion/{promotionsKey}")
    void deleteEsGoodsPromotionByPromotionKey(@RequestBody List<String> skuIds, @PathVariable String promotionsKey);


    /**
     * 删除索引中指定的促销活动id的促销活动
     *
     * @param promotionsKey 促销活动Key
     */
    @DeleteMapping("/feign/goods/esGoods/deleteEsGoodsPromotionByPromotionKey/{promotionsKey}")
    void deleteEsGoodsPromotionByPromotionKey(@PathVariable String promotionsKey);
}
